package com.example.kotlinproject.modules.login

import android.content.Context
import com.example.kotlinproject.entity.LoginResponse
import com.example.kotlinproject.modules.login.inter.LoginModule
import com.example.kotlinproject.modules.login.inter.LoginPresenter
import com.example.kotlinproject.modules.login.inter.LoginView


//var view:LoginView  加了var表示他是个成员变量,不加表示他是个参数
class LoginPresentImpl(var view:LoginView?):LoginPresenter {
    private val loginModel: LoginModule = LoginModuleImpl()
    override fun login(context: Context, username: String, password: String) {
        loginModel.login(context,username,password,object :LoginPresenter.OnLoginListener{
            override fun loginSuccess(loginBean: LoginResponse?) {
                view?.loginSuccess(loginBean)
            }
            override fun loginFialure(erroeMsg: String?) {
               view?.loginFailure(erroeMsg)
           }

        })
    }

    override fun unAttachView() {
        view = null
    }


}